#! /usr/bin/python
import sys

f = open("libtest.py", "r")
line = f.readline()
while line:
    print line
    line = f.readline()

print "=========================="
f = open("testwrite.txt", "a")
f.write("hello world\n")
f.close()

f = open("testwrite.txt", "a+")
print "file pos before read:", f.tell()
c = f.read()
while c:
    print c
    c = f.read()
f.seek(0,0)
f.write("test append\n")
print "file pos after append:", f.tell()
print "--------------------------"
print "file pos before second read:",f.tell()
f.seek(0, 0)
c = f.read()
while c:
    print c
    c = f.read()

inputstr = sys.stdin.readline()
cnt = 3
while inputstr and cnt > 0:
    print "echo:", inputstr
    cnt = cnt - 1
    #inputstr = sys.stdin.readline()
